<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="handleTabClick">
      <el-tab-pane v-for="item, index in bundles" :label="item.name" :name="String(index)" :key="index"></el-tab-pane>
    </el-tabs>

    <el-form :inline="true" :model="formData">
      <el-form-item label="组件名：">
        <el-input v-model="formData.bundle"></el-input>
      </el-form-item>
      <el-form-item label="组件名：">
        <el-input v-model="formData.bundle"></el-input>
      </el-form-item>
      <el-form-item label="组件名：">
        <el-input v-model="formData.bundle"></el-input>
      </el-form-item>
      <el-form-item label="组件名：">
        <el-input v-model="formData.bundle"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import {mixins} from "@/core";

  export default {
    mixins: [mixins],
    data () {
      return {
        formData: {
          bundle: ""
        },
        activeName: "0",
        bundles: [{
          name: "SV-02",
          serverId: 2
        },{
          name: "SV-03",
          serverId: 3
        },{
          name: "SV-01",
          serverId: 65
        }],
        API: {
          query: "/gafe/bundles"
        }
      }
    },
    created () {
      this.API.query += "?serverId=" + this.bundles[0].serverId;
    },
    methods: {
      handleTabClick(tab, event) {
        const obj = this.bundles.forEach((item) => {
          if (item.name === tab.label) {
            this.API.query = "/gafe/bundles?serverId=" + item.serverId;
            this.getTableData();
          }
        });
      }
    }
  }
</script>
